package util

import (
	"zin/framework"
	"zin/framework/contract"
)

var Container *framework.FmkContainer

// GetAppProvider appProvider
func GetAppProvider() contract.IContractApp {
	return Container.MustMake(contract.ProviderKeyApp).(contract.IContractApp)
}

// GetEnvProvider envProvider
func GetEnvProvider() contract.IContractEnv {
	return Container.MustMake(contract.ProviderKeyEnv).(contract.IContractEnv)
}

// GetLogProvider logProvider
func GetLogProvider() contract.IContractLog {
	return Container.MustMake(contract.ProviderKeyLog).(contract.IContractLog)
}

// GetTraceProvider traceProvider
func GetTraceProvider() contract.IContractTrace {
	return Container.MustMake(contract.ProviderKeyTrace).(contract.IContractTrace)
}

// GetIdProvider idProvider
func GetIdProvider() contract.IContractId {
	return Container.MustMake(contract.ProviderKeyId).(contract.IContractId)
}

// GetRedisProvider redisProvider
func GetRedisProvider() contract.IContractRedis {
	return Container.MustMake(contract.ProviderKeyRedis).(contract.IContractRedis)
}

// GetCacheProvider cacheProvider
func GetCacheProvider() contract.IContractCache {
	return Container.MustMake(contract.ProviderKeyCache).(contract.IContractCache)
}

// GetOrmProvider ormProvider
func GetOrmProvider() contract.IContractOrm {
	return Container.MustMake(contract.ProviderKeyOrm).(contract.IContractOrm)
}

func SetContainer(c *framework.FmkContainer) {
	Container = c
}
